package com.osgix.common.utils.xmlUtil.impl;

import java.io.Reader;
import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import com.osgix.common.utils.xmlUtil.IXmlParser;

public class XmlParserImpl implements IXmlParser {
	/* (non-Javadoc)
	 * @see com.thuni.tools.xmlUtil.iface.IXmlParser#paeseXml(java.lang.String, java.lang.Class)
	 */
	public Object paeseXml(String xmlStr, Class c) {
		try {
			JAXBContext context = JAXBContext.newInstance(c);
			Unmarshaller u = context.createUnmarshaller();
			Reader sr = new StringReader(xmlStr);
			Object obj = u.unmarshal(sr);
			return obj;
		} catch (JAXBException e) {
			e.printStackTrace();
		}
		return null;
	}
}
